<!doctype html>
<html lang="zh-CN">
<head>

    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    
    <meta name="referrer" content="no-referrer-when-downgrade">
    

    <title>Vue组件开发以及常用全局api | 早起的年轻人</title>
    <meta property="og:title" content="Vue组件开发以及常用全局api - 早起的年轻人">
    <meta property="og:type" content="article">
        
    <meta property="article:published_time" content='2021-09-16T08:49:43&#43;08:00'>
        
        
    <meta property="article:modified_time" content='2021-09-16T08:49:43&#43;08:00'>
        
    <meta name="Keywords" content="Flutter，golang,go语言,go语言笔记,飞雪无情,java,android,博客,项目管理,python,软件架构,公众号,小程序">
    <meta name="description" content="Vue组件开发以及常用全局api">
        
    <meta name="author" content="luckly">
    <meta property="og:url" content="https://luckly.work/post/vue/Vue%E7%BB%84%E4%BB%B6%E5%BC%80%E5%8F%91%E4%BB%A5%E5%8F%8A%E5%B8%B8%E7%94%A8%E5%85%A8%E5%B1%80api/">
    <link rel="shortcut icon" href='/favicon.ico'  type="image/x-icon">

    <link rel="stylesheet" href='/css/normalize.css'>
    <link rel="stylesheet" href='/css/style.css'>
    <script type="text/javascript" src="//cdn.bootcdn.net/ajax/libs/jquery/3.4.1/jquery.min.js"></script>

    
    
    
        <link href="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.css" rel="stylesheet">
    
    
    
    
        <link rel="stylesheet" href='/css/douban.css'>
    
        <link rel="stylesheet" href='/css/other.css'>
    
</head>

<link rel="stylesheet"
      href="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/styles/default.min.css">
<script src="//cdnjs.cloudflare.com/ajax/libs/highlight.js/11.2.0/highlight.min.js"></script>
<body>
    <header id="header" class="clearfix">
    <div class="container">
        <div class="col-group">
            <div class="site-name ">
                
                    <a id="logo" href="https://luckly.work/">
                        早起的年轻人
                    </a>
                
                <p class="description">专注于Flutter、Android、Java、Go语言(golang)、移动互联网、项目管理、软件架构</p>
            </div>
            <div>
                <nav id="nav-menu" class="clearfix">
                    <a class="current" href="https://luckly.work/">首页</a>
                    
                    <a  href="https://luckly.work/categories/" title="分类">分类</a>
                    
                    <a  href="https://luckly.work/tags/" title="标签">标签</a>
                    
                    <a  href="https://luckly.work/archives/" title="归档">归档</a>
                    
                    <a  href="https://luckly.work/about/" title="关于我">关于我</a>
                    
                    <a  href="https://github.com/ITmxs/" title="github">github</a>
                    
                </nav>
            </div>
        </div>
    </div>
</header>

    <div id="body">
        <div class="container">
            <div class="col-group">

                <div class="col-8" id="main">
                    
<div class="res-cons">
    <style type="text/css">
    .post-toc {
        position: fixed;
        width: 200px;
        margin-left: -210px;
        padding: 5px 10px;
        font-family: Athelas, STHeiti, Microsoft Yahei, serif;
        font-size: 12px;
        border: 1px solid rgba(0, 0, 0, .07);
        border-radius: 5px;
        background-color: rgba(255, 255, 255, 0.98);
        background-clip: padding-box;
        -webkit-box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        box-shadow: 1px 1px 2px rgba(0, 0, 0, .125);
        word-wrap: break-word;
        white-space: nowrap;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
        z-index: 999;
        cursor: pointer;
        max-height: 70%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .post-toc .post-toc-title {
        width: 100%;
        margin: 0 auto;
        font-size: 20px;
        font-weight: 400;
        text-transform: uppercase;
        text-align: center;
    }

    .post-toc .post-toc-content {
        font-size: 15px;
    }

    .post-toc .post-toc-content>nav>ul {
        margin: 10px 0;
    }

    .post-toc .post-toc-content ul {
        padding-left: 20px;
        list-style: square;
        margin: 0.5em;
        line-height: 1.8em;
    }

    .post-toc .post-toc-content ul ul {
        padding-left: 15px;
        display: none;
    }

    @media print,
    screen and (max-width:1057px) {
        .post-toc {
            display: none;
        }
    }
</style>
<div class="post-toc" style="position: absolute; top: 188px;">
    <h2 class="post-toc-title">文章目录</h2>
    <div class="post-toc-content">
        <nav id="TableOfContents">
  <ul>
    <li>
      <ul>
        <li><a href="#生命周期">生命周期</a></li>
        <li><a href="#组件创建">组件创建</a></li>
        <li><a href="#组件里面套组件父子组件">组件里面套组件（父子组件）</a></li>
        <li><a href="#插槽-slot">插槽 slot</a></li>
        <li><a href="#prop-传递参数给组件父传值给子">prop 传递参数给组件（父传值给子）</a></li>
        <li><a href="#子组件传值给父组件">子组件传值给父组件</a></li>
        <li><a href="#其余会用到的全局-api">其余会用到的全局 API</a></li>
      </ul>
    </li>
  </ul>
</nav>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        var postToc = $(".post-toc");
        if (postToc.length) {
            var leftPos = $("#main").offset().left;
            if(leftPos<220){
                postToc.css({"width":leftPos-10,"margin-left":(0-leftPos)})
            }

            var t = postToc.offset().top - 20,
                a = {
                    start: {
                        position: "absolute",
                        top: t
                    },
                    process: {
                        position: "fixed",
                        top: 20
                    },
                };
            $(window).scroll(function () {
                var e = $(window).scrollTop();
                e < t ? postToc.css(a.start) : postToc.css(a.process)
            })
        }
    })
</script>
    <article class="post">
        <header>
            <h1 class="post-title">Vue组件开发以及常用全局api</h1>
        </header>
        <date class="post-meta meta-date">
            2021年9月16日
        </date>
        
        <div class="post-meta">
            <span>|</span>
            
            <span class="meta-category"><a href='/categories/Vue'>Vue</a></span>
            
        </div>
        
        
        <div class="post-meta">
            <span id="busuanzi_container_page_pv">|<span id="busuanzi_value_page_pv"></span><span>
                    阅读</span></span>
        </div>
        
        
        <div class="post-content">
            <h3 id="生命周期">生命周期</h3>
<p><strong>Vue 官网给出的生命周期图</strong></p>
<p>
        <a data-fancybox="gallery" href="https://luckly007.oss-cn-beijing.aliyuncs.com/image/lifecycle.png">
            <img class="mx-auto" alt="Vue 实例生命周期" src="https://luckly007.oss-cn-beijing.aliyuncs.com/image/lifecycle.png" />
        </a>
    </p>
<p>
    
    
        <a data-fancybox="gallery" href="https://cdn.jsdelivr.net/gh/ITmxs/ITmxs.github.io/post/vue/Vue%E7%BB%84%E4%BB%B6%E5%BC%80%E5%8F%91%E4%BB%A5%E5%8F%8A%E5%B8%B8%E7%94%A8%E5%85%A8%E5%B1%80api/">
            <img class="mx-auto" alt="img" src="https://cdn.jsdelivr.net/gh/ITmxs/ITmxs.github.io/post/vue/Vue%E7%BB%84%E4%BB%B6%E5%BC%80%E5%8F%91%E4%BB%A5%E5%8F%8A%E5%B8%B8%E7%94%A8%E5%85%A8%E5%B1%80api/" />
        </a>
    
这张图里包含了基本的生命周期，实际上生命周期钩子函数还有两个不在图内（activated，deactivated），这两个生命周期函数这里不给大家讲，如果大家有兴趣可以自行到 VUE 官网看文档，工作中用到他们的机会不多，这边讲也会扰乱大家的学习进程。这里我们通过代码来讲解 Vue 的生命周期</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
    &lt;<span style="color:#f92672">style</span>&gt;
		.<span style="color:#a6e22e">active</span>{
			<span style="color:#66d9ef">color</span>:<span style="color:#66d9ef">red</span>
		}
	&lt;/<span style="color:#f92672">style</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
	    &lt;<span style="color:#f92672">button</span> <span style="color:#a6e22e">v-on:click</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;add&#34;</span>&gt;+&lt;/<span style="color:#f92672">button</span>&gt;{{num}}&lt;<span style="color:#f92672">button</span> <span style="color:#960050;background-color:#1e0010">@</span><span style="color:#a6e22e">click</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;minus&#34;</span>&gt;-&lt;/<span style="color:#f92672">button</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
               <span style="color:#a6e22e">num</span><span style="color:#f92672">:</span><span style="color:#ae81ff">1</span>
            },
            <span style="color:#a6e22e">methods</span><span style="color:#f92672">:</span>{
	            <span style="color:#a6e22e">add</span>(){
		            <span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">num</span><span style="color:#f92672">++</span>
	            },
	            <span style="color:#a6e22e">minus</span>(){
		             <span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">num</span><span style="color:#f92672">--</span>
	            }
			},
            <span style="color:#a6e22e">beforeCreate</span><span style="color:#f92672">:</span><span style="color:#66d9ef">function</span>(){
                <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;页面初始化之后立刻执行&#39;</span>);
            },
            <span style="color:#a6e22e">created</span><span style="color:#f92672">:</span><span style="color:#66d9ef">function</span>(){
                <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;页面初始化完成之后created,这里模板还没有渲染呢！&#39;</span>);
            },
            <span style="color:#a6e22e">beforeMount</span><span style="color:#f92672">:</span><span style="color:#66d9ef">function</span>(){
                <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;组件挂载之前beforeMount&#39;</span>);
            },
            <span style="color:#a6e22e">mounted</span><span style="color:#f92672">:</span><span style="color:#66d9ef">function</span>(){
                <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;组件挂载之后mounted&#39;</span>);
            },
            <span style="color:#a6e22e">beforeUpdate</span><span style="color:#f92672">:</span><span style="color:#66d9ef">function</span>(){
                <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;组件更新前beforeUpdate&#39;</span>);
            },
            <span style="color:#a6e22e">updated</span><span style="color:#f92672">:</span><span style="color:#66d9ef">function</span>(){
                <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;组件更新后updated&#39;</span>);
            },
        <span style="color:#75715e">//   activated:function(){
</span><span style="color:#75715e"></span>        <span style="color:#75715e">//      console.log(&#39;activated&#39;);
</span><span style="color:#75715e"></span>        <span style="color:#75715e">//    },
</span><span style="color:#75715e"></span>        <span style="color:#75715e">//    deactivated:function(){
</span><span style="color:#75715e"></span>        <span style="color:#75715e">//        console.log(&#39;deactivated&#39;);
</span><span style="color:#75715e"></span>        <span style="color:#75715e">//    },    你只需要知道这两个生命周期是在这个位置进行就好了，别的可以不要想太多。
</span><span style="color:#75715e"></span>            <span style="color:#a6e22e">beforeDestroy</span><span style="color:#f92672">:</span><span style="color:#66d9ef">function</span>(){
                <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;组件销毁之前beforeDestroy&#39;</span>);
            },
            <span style="color:#a6e22e">destroyed</span><span style="color:#f92672">:</span><span style="color:#66d9ef">function</span>(){
                <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#e6db74">&#39;组件销毁后destroyed&#39;</span>)
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
</code></pre></div><p>这些生命周期函数大体就演示到这里，剩下的两个没能给大家展示的请大家牢记，我们开始学组件的时候，就可以体会到这两个钩子函数的用法了。</p>
<h3 id="组件创建">组件创建</h3>
<p><strong>Vue.component</strong>
注册全局组件
Vue.component(&ldquo;组件名&rdquo;，{ 组件的各种属性（模板啊，data 啊，方法啊，生命周期啊之类的。） }), （视频里有一句口误，应该是小驼峰。手动捂脸）</p>
<p>这个全局 API 看过以后，我们来实现一个组件的 hello world</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
       &lt;<span style="color:#f92672">shuai-qm</span>&gt;&lt;/<span style="color:#f92672">shuai-qm</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
        <span style="color:#a6e22e">Vue</span>.<span style="color:#a6e22e">component</span>(<span style="color:#e6db74">&#34;shuai-qm&#34;</span>,{
            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;hello world&#39;</span>
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;&lt;h1&gt;{{hello}}&lt;/h1&gt;&#39;</span>
        })
        
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">message</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;Hello Word&#39;</span>,
                <span style="color:#a6e22e">isTrue</span><span style="color:#f92672">:</span><span style="color:#66d9ef">true</span>,
            },
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
</code></pre></div><p>一个全局组件的 hello world 就完成了，但是大家是不是觉得全局组件非常不踏实？随时可能一个变动摧毁我们的项目？
那没关系，接下来是局部组建的注册方法。</p>
<p><strong>Vue 的 components 属性</strong></p>
<p>我们在注册局部组建的时候，需要把局部组建挂载到 Vue 构造器的 components 内，注意：全局 API 不带 s，而这个属性带 s。不说废话，我们先来构造一个。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
    {{message}}
	   &lt;<span style="color:#f92672">shuai-qm</span>&gt;&lt;/<span style="color:#f92672">shuai-qm</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">message</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;Hello World&#39;</span>,
                <span style="color:#a6e22e">isTrue</span><span style="color:#f92672">:</span><span style="color:#66d9ef">true</span>,
            },
              <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                   <span style="color:#e6db74">&#34;shuaiQm&#34;</span><span style="color:#f92672">:</span>{
                       <span style="color:#a6e22e">data</span>(){
                           <span style="color:#66d9ef">return</span>{
                               <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>
                           }
                       },
                       <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;&lt;h1&gt;{{hello}}&lt;/h1&gt;&#39;</span>
                       }
                }
            
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
</code></pre></div><p>这样我们就得到了一个可以 hello world 的局部组件，但是，一堆组建都这个样子罗列出来的话，会将我们的项目弄得体无完肤？
所以我们抽离一下代码。变成这样</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
    {{message}}
	  &lt;<span style="color:#f92672">shuai-qm</span>&gt;&lt;/<span style="color:#f92672">shuai-qm</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">shuaiQm</span> <span style="color:#f92672">=</span> {
            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;&lt;h1&gt;{{hello}}&lt;/h1&gt;&#39;</span>
            }
 
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">message</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;Hello World&#39;</span>,
                <span style="color:#a6e22e">isTrue</span><span style="color:#f92672">:</span><span style="color:#66d9ef">true</span>,
            },
            <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                   <span style="color:#e6db74">&#34;shuaiQm&#34;</span><span style="color:#f92672">:</span><span style="color:#a6e22e">shuaiQm</span>,
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
</code></pre></div><p>是不是用 vue-cli 开发过的同学就比较眼熟了？那么问题又来了，组件里面的 HTML 全都是写的字符串，都这么玩下去，要乱死啊，没问题，我们继续抽离。</p>
<p>这里介绍的就是 vue 的 template 用法了，马上又是一个 cli 党眼熟的东西</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">template</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;shuaiQm&#34;</span>&gt;
    &lt;<span style="color:#f92672">h1</span>&gt;{{hello}}&lt;/<span style="color:#f92672">h1</span>&gt;
&lt;/<span style="color:#f92672">template</span>&gt;
 
<span style="color:#75715e">&lt;!-- 上面是html模板的用法，下面是script模板的用法，使用&lt;script&gt;标签时，type指定为text/x-template，意在告诉浏览器这不是一段js脚本，浏览器在解析HTML文档时会忽略&lt;script&gt;标签内定义的内容。--&gt;</span>
 
<span style="color:#75715e">&lt;!-- 推荐 --&gt;</span>
&lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;x-template&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;shuaiQm2&#34;</span>&gt;
    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">h2</span> <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;color:blue&#34;</span><span style="color:#f92672">&gt;</span>{{<span style="color:#a6e22e">hello</span>}}<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/h2&gt;</span>
&lt;/<span style="color:#f92672">script</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
    {{message}}
	   &lt;<span style="color:#f92672">shuai-qm</span>&gt;&lt;/<span style="color:#f92672">shuai-qm</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">shuaiQm</span> <span style="color:#f92672">=</span> {
            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#shuaiQm2&#34;</span>
            }
 
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">message</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;Hello World&#39;</span>,
                <span style="color:#a6e22e">isTrue</span><span style="color:#f92672">:</span><span style="color:#66d9ef">true</span>,
            },
            <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                   <span style="color:#e6db74">&#34;shuaiQm&#34;</span><span style="color:#f92672">:</span><span style="color:#a6e22e">shuaiQm</span>,
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
</code></pre></div><p>拆出来以后是不是莫名其妙引起了极度舒适？当然后面我们学到使用 vue-cli 的时候 我们还会用到新的书写方法 .vue 文件的方法，这里就先不给大家多说了。</p>
<h3 id="组件里面套组件父子组件">组件里面套组件（父子组件）</h3>
<p>可能由同学会问了，组件里面还可以嵌套组件吗？我可以很负责任地告诉你，完全没问题！怎么写呢？你如果会在 Vue 实例的构造器里引用组件，你就会在别的组件内部引用组件，他们其实是一个写法。这边我使用我们的第三种模板写法来给大家书写。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;x-template&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;father&#34;</span>&gt;
  <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">div</span><span style="color:#f92672">&gt;</span>
    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">h2</span> <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;color:blue&#34;</span><span style="color:#f92672">&gt;</span>{{<span style="color:#a6e22e">hello</span>}}<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/h2&gt;</span>
    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">childer</span>  <span style="color:#f92672">/&gt;</span>
  <span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/div&gt;</span>
&lt;/<span style="color:#f92672">script</span>&gt;
 
&lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;x-template&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;childer&#34;</span>&gt;
    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">h2</span> <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;color:blue&#34;</span><span style="color:#f92672">&gt;</span>{{<span style="color:#a6e22e">hello</span>}}<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/h2&gt;</span>
&lt;/<span style="color:#f92672">script</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
    {{message}}
	&lt;<span style="color:#f92672">shuai-qm</span>&gt;&lt;/<span style="color:#f92672">shuai-qm</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">childer</span> <span style="color:#f92672">=</span> {
            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello i&#39;m dawangraoming&#34;</span>
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#childer&#34;</span>
        }
 
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">father</span> <span style="color:#f92672">=</span> {
            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#father&#34;</span>,
            <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                <span style="color:#e6db74">&#34;childer&#34;</span><span style="color:#f92672">:</span><span style="color:#a6e22e">childer</span>
            }
            }
 
 
 
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">message</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;Hello World&#39;</span>,
                <span style="color:#a6e22e">isTrue</span><span style="color:#f92672">:</span><span style="color:#66d9ef">true</span>,
            },
            <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                   <span style="color:#e6db74">&#34;shuaiQm&#34;</span><span style="color:#f92672">:</span><span style="color:#a6e22e">father</span>,
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
 
</code></pre></div><p>这里大家也可以看到，我们在 app 内部只引用了 shuaiQm 这一个组件， shuaiQm 又包含他的子组件 childer，因此父子都被渲染出来了。这就是父子组件的写法。</p>
<h3 id="插槽-slot">插槽 slot</h3>
<p>这时候又有朋友要问了，如果我想在组件里面继续书写 HTML 怎么办呢？ slot 插槽就是个很好的东西了，这里我用代码给大家演示一下 slot 插槽的用法。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;x-template&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;shuaiQm2&#34;</span>&gt;
    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">div</span> <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;color:blue&#34;</span><span style="color:#f92672">&gt;</span>
        <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">h2</span><span style="color:#f92672">&gt;</span>{{<span style="color:#a6e22e">hello</span>}}<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/h2&gt;</span>
        <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">solt</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;solt1&#34;</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">我是插槽solt1</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/solt&gt;</span>
        <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">solt</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;solt2&#34;</span><span style="color:#f92672">&gt;</span><span style="color:#a6e22e">我是插槽solt2</span><span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/solt&gt;</span>
        <span style="color:#75715e">&lt;!--</span> <span style="color:#a6e22e">如果插槽不使用的话</span><span style="color:#960050;background-color:#1e0010">，</span><span style="color:#a6e22e">内部的默认文字就会展示出来</span> <span style="color:#f92672">--&gt;</span>
    <span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/div&gt;</span>
&lt;/<span style="color:#f92672">script</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
    {{message}}
	   &lt;<span style="color:#f92672">shuai-qm</span>&gt;
           &lt;<span style="color:#f92672">span</span> <span style="color:#a6e22e">slot</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;solt1&#34;</span>&gt;hello world&lt;/<span style="color:#f92672">span</span>&gt;
       &lt;/<span style="color:#f92672">shuai-qm</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">shuaiQm</span> <span style="color:#f92672">=</span> {
            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#shuaiQm2&#34;</span>
            }
 
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">message</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;Hello World&#39;</span>,
                <span style="color:#a6e22e">isTrue</span><span style="color:#f92672">:</span><span style="color:#66d9ef">true</span>,
            },
            <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                   <span style="color:#e6db74">&#34;shuaiQm&#34;</span><span style="color:#f92672">:</span><span style="color:#a6e22e">shuaiQm</span>,
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
</code></pre></div><p>插槽只有这一个作用吗？不，那你就太小看插槽了，接下来要介绍一下插槽的作用域插槽用法。</p>
<p><strong>作用域插槽，听不懂可跳过，后面还会详细讲解</strong></p>
<p>使用时候子组件标签 Child 中要有 template scope=”scopeName” 标签，再通过 scopeName.childProp 就可以调用子组件模板中的 childProp 绑定的数据，所以作用域插槽是一种子传父传参的方式，解决了普通 slot 在 parent 中无法访问 child 数据的去问题；
这么说太复杂了，直接上个例子显而易见。
如果这里听不懂可以暂时跳过，只需要会用 slot 插槽的基础用法即可，在后面讲 Element 项目的时候，我会结合实例给大家讲解这个作用域插槽。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;en&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;x-template&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;shuaiQm2&#34;</span>&gt;
    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">div</span> <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;color:blue&#34;</span><span style="color:#f92672">&gt;</span>
        <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">h2</span><span style="color:#f92672">&gt;</span>{{<span style="color:#a6e22e">hello</span>}}<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/h2&gt;</span>
        <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">slot</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;item&#34;</span> <span style="color:#a6e22e">v</span><span style="color:#f92672">-</span><span style="color:#66d9ef">for</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;item in items&#34;</span> <span style="color:#f92672">:</span><span style="color:#a6e22e">text</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;item.text&#34;</span> <span style="color:#f92672">:</span><span style="color:#a6e22e">myname</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;item.myname&#34;</span> <span style="color:#f92672">&gt;</span>
            <span style="color:#a6e22e">slot的默认内容</span>
        <span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/slot&gt;</span>
    <span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/div&gt;</span>
&lt;/<span style="color:#f92672">script</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
    {{message}}
	   &lt;<span style="color:#f92672">shuai-qm</span>&gt;
          &lt;<span style="color:#f92672">template</span> <span style="color:#a6e22e">slot</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;item&#34;</span> <span style="color:#a6e22e">scope</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;props&#34;</span>&gt;
            &lt;<span style="color:#f92672">li</span>&gt;{{props.myname}}&lt;/<span style="color:#f92672">li</span>&gt;
            &lt;<span style="color:#f92672">li</span>&gt;{{props.text}}&lt;/<span style="color:#f92672">li</span>&gt;
          &lt;/<span style="color:#f92672">template</span>&gt;
       &lt;/<span style="color:#f92672">shuai-qm</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">shuaiQm</span> <span style="color:#f92672">=</span> {
            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>,
                    <span style="color:#a6e22e">items</span><span style="color:#f92672">:</span>[{
                      <span style="color:#a6e22e">text</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;我在子组件内，通过插槽展示在父组件&#34;</span>,
                      <span style="color:#a6e22e">myname</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;Qm&#34;</span>,
                    },{
                      <span style="color:#a6e22e">text</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;我在子组件内，通过插槽展示在父组件&#34;</span>,
                      <span style="color:#a6e22e">myname</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;奇淼&#34;</span>,
                    }]
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#shuaiQm2&#34;</span>
            }
 
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">message</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;Hello World&#39;</span>,
                <span style="color:#a6e22e">isTrue</span><span style="color:#f92672">:</span><span style="color:#66d9ef">true</span>,
            },
            <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                   <span style="color:#e6db74">&#34;shuaiQm&#34;</span><span style="color:#f92672">:</span><span style="color:#a6e22e">shuaiQm</span>,
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
</code></pre></div><h3 id="prop-传递参数给组件父传值给子">prop 传递参数给组件（父传值给子）</h3>
<p>讲到这里，已经到了 VUE 一个需要理解的地方了，父子传值，我们先讲解一下，如何将值传递给子组件，这个整体来说还是比较简单。引用我们的组件的标签上写上属性，并且把参数传入，这样我们在组件内部使用 props 就可以获得传过来的值了，我们还是以上面的代码为例。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;zh-cn&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;x-template&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;father&#34;</span>&gt;
  <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">div</span><span style="color:#f92672">&gt;</span>
    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">h2</span> <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;color:blue&#34;</span><span style="color:#f92672">&gt;</span>{{<span style="color:#a6e22e">hello</span>}}<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/h2&gt;</span>
    {{<span style="color:#a6e22e">apptoshuaiqm</span>}}
    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">childer</span> <span style="color:#f92672">:</span><span style="color:#a6e22e">shuai</span><span style="color:#f92672">-</span><span style="color:#a6e22e">qmtochilder</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;shuaiQmGiveMe&#34;</span> <span style="color:#f92672">/&gt;</span>
  <span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/div&gt;</span>
&lt;/<span style="color:#f92672">script</span>&gt;
 
&lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;x-template&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;childer&#34;</span>&gt;
    <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">div</span><span style="color:#f92672">&gt;</span>
        <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">h2</span> <span style="color:#a6e22e">style</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;color:blue&#34;</span><span style="color:#f92672">&gt;</span>{{<span style="color:#a6e22e">hello</span>}}<span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/h2&gt;</span>
        {{<span style="color:#a6e22e">shuaiQmtochilder</span>}}
    <span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/div&gt;</span>
&lt;/<span style="color:#f92672">script</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
	&lt;<span style="color:#f92672">shuai-qm</span> <span style="color:#a6e22e">apptoshuaiqm</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;我是app传过来的值&#34;</span> &gt;&lt;/<span style="color:#f92672">shuai-qm</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">childer</span> <span style="color:#f92672">=</span> {
          <span style="color:#a6e22e">props</span><span style="color:#f92672">:</span>[<span style="color:#e6db74">&#39;shuaiQmtochilder&#39;</span>],
            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello i&#39;m dawangraoming&#34;</span>,
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#childer&#34;</span>
        }
 
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">father</span> <span style="color:#f92672">=</span> {
            <span style="color:#a6e22e">props</span><span style="color:#f92672">:</span>[<span style="color:#e6db74">&#34;apptoshuaiqm&#34;</span>],<span style="color:#75715e">// 这里大家一定要注意，请完全使用小写传参
</span><span style="color:#75715e"></span>            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>,
                    <span style="color:#a6e22e">shuaiQmGiveMe</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;我是从shuaiQm传过来的值&#34;</span>
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#father&#34;</span>,
            <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                <span style="color:#e6db74">&#34;childer&#34;</span><span style="color:#f92672">:</span><span style="color:#a6e22e">childer</span>
            }
            }
 
 
 
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">message</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#39;Hello World&#39;</span>,
                <span style="color:#a6e22e">isTrue</span><span style="color:#f92672">:</span><span style="color:#66d9ef">true</span>,
            },
            <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                   <span style="color:#e6db74">&#34;shuaiQm&#34;</span><span style="color:#f92672">:</span><span style="color:#a6e22e">father</span>,
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
 
</code></pre></div><p>这一段代码注意，再给 HTML 上面添加属性的时候，我们是不可以直接添加驼峰命名的，因为 HTML 不会区分大小写，所以我们建议属性的命名方式是完全小写或者横线命名的方式。如果我们使用横线命名来传递参数的话，在接收的时候，横线后面的首字母大写，变成小驼峰来接受，否则使用的时候它会被渲染成 NaN，这是为什么呢？别忘了我们一档讲过的，在插值表达式内，是支持简单计算的，- 会被当作减号处理，这里我会在视频中给大家详细讲解。</p>
<h3 id="子组件传值给父组件">子组件传值给父组件</h3>
<p>学到这里，如果大家已经有些迷茫，现在请先停下，喘口气，这里难度已经慢慢加大。我也会放慢讲解的速度。
如果我们想要获取到子组件内部的值，该怎么办呢？有什么办法能够让我们回去到内部的值呢？在这里，先给大家插播一个 JS 写法，我觉得这有助于理解子传父值。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js"><span style="color:#66d9ef">function</span> <span style="color:#a6e22e">thief</span> (<span style="color:#a6e22e">gold</span>) {
    <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#a6e22e">gold</span>)
}
 
<span style="color:#66d9ef">function</span> <span style="color:#a6e22e">richMan</span> (){
    <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">money</span> <span style="color:#f92672">=</span> <span style="color:#ae81ff">1000086</span>
    <span style="color:#a6e22e">thief</span>(<span style="color:#a6e22e">money</span>)
}
 
<span style="color:#a6e22e">richMan</span>()
</code></pre></div><p>我们想要在 vue 中做到子传参给父，那我们的父组件就要像子组件伸出小偷之手。我在代码中为大家书写一下</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;zh-cn&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;x-template&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;shuaiQm&#34;</span>&gt;
  <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">div</span><span style="color:#f92672">&gt;</span>
   
  <span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/div&gt;</span>
&lt;/<span style="color:#f92672">script</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
      {{qmGold}}
	&lt;<span style="color:#f92672">shuai-qm</span> <span style="color:#a6e22e">:father</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;thief&#34;</span>&gt;&lt;/<span style="color:#f92672">shuai-qm</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">shuaiQm</span> <span style="color:#f92672">=</span> {
            <span style="color:#a6e22e">props</span><span style="color:#f92672">:</span>[<span style="color:#e6db74">&#34;father&#34;</span>],
            <span style="color:#a6e22e">data</span>(){
                <span style="color:#66d9ef">return</span>{
                    <span style="color:#a6e22e">money</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;10000&#34;</span>,
                }
            },
            <span style="color:#a6e22e">template</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#shuaiQm&#34;</span>,
            <span style="color:#a6e22e">created</span>() {
              <span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">father</span>(<span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">money</span>)
            },
            }
 
 
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
              <span style="color:#a6e22e">qmGold</span><span style="color:#f92672">:</span><span style="color:#ae81ff">0</span>,
            },
            <span style="color:#a6e22e">components</span><span style="color:#f92672">:</span>{
                   <span style="color:#e6db74">&#34;shuaiQm&#34;</span><span style="color:#f92672">:</span><span style="color:#a6e22e">shuaiQm</span>,
            },
            <span style="color:#a6e22e">methods</span><span style="color:#f92672">:</span>{
              <span style="color:#a6e22e">thief</span>(<span style="color:#a6e22e">gold</span>){
                <span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">qmGold</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">gold</span>
              }
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
 
</code></pre></div><p>这样 你理解子传参给父了吗？</p>
<h3 id="其余会用到的全局-api">其余会用到的全局 API</h3>
<p><strong>Vue.directivet</strong>
Vue.directive 我们用来编写全局指令，它也有自己的生命周期</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js"><span style="color:#75715e">// 注册
</span><span style="color:#75715e"></span><span style="color:#a6e22e">Vue</span>.<span style="color:#a6e22e">directive</span>(<span style="color:#e6db74">&#39;my-directive&#39;</span>, {
  <span style="color:#a6e22e">bind</span><span style="color:#f92672">:</span> <span style="color:#66d9ef">function</span> () {},
  <span style="color:#a6e22e">inserted</span><span style="color:#f92672">:</span> <span style="color:#66d9ef">function</span> () {},
  <span style="color:#a6e22e">update</span><span style="color:#f92672">:</span> <span style="color:#66d9ef">function</span> () {},
  <span style="color:#a6e22e">componentUpdated</span><span style="color:#f92672">:</span> <span style="color:#66d9ef">function</span> () {},
  <span style="color:#a6e22e">unbind</span><span style="color:#f92672">:</span> <span style="color:#66d9ef">function</span> () {}
})
 
<span style="color:#75715e">/*
</span><span style="color:#75715e">bind：只调用一次，指令第一次绑定到元素时调用。在这里可以进行一次性的初始化设置。
</span><span style="color:#75715e">
</span><span style="color:#75715e">inserted：被绑定元素插入父节点时调用 (仅保证父节点存在，但不一定已被插入文档中)。
</span><span style="color:#75715e">
</span><span style="color:#75715e">update：所在组件的 VNode 更新时调用，但是可能发生在其子 VNode 更新之前。指令的值可能发生了改变，也可能没有。但是你可以通过比较更新前后的值来忽略不必要的模板更新 (详细的钩子函数参数见下)。
</span><span style="color:#75715e">
</span><span style="color:#75715e">componentUpdated：指令所在组件的 VNode 及其子 VNode 全部更新后调用。
</span><span style="color:#75715e">
</span><span style="color:#75715e">unbind：只调用一次，指令与元素解绑时调用。
</span><span style="color:#75715e">
</span><span style="color:#75715e">接下来我们来看一下钩子函数的参数 (即 el、binding、vnode 和 oldVnode)。
</span><span style="color:#75715e">
</span><span style="color:#75715e">在这些钩子函数内部，都可以接受三个参数，我们来看看文档中的写法。
</span><span style="color:#75715e">el：指令所绑定的元素，可以用来直接操作 DOM 。
</span><span style="color:#75715e">
</span><span style="color:#75715e">binding：一个对象，包含以下属性：
</span><span style="color:#75715e">    name：指令名，不包括 v- 前缀。
</span><span style="color:#75715e">    value：指令的绑定值，例如：v-my-directive=&#34;1 + 1&#34; 中，绑定值为 2。
</span><span style="color:#75715e">    oldValue：指令绑定的前一个值，仅在 update 和 componentUpdated 钩子中可用。无论值是否改变都可用。
</span><span style="color:#75715e">    expression：字符串形式的指令表达式。例如 v-my-directive=&#34;1 + 1&#34; 中，表达式为 &#34;1 + 1&#34;。
</span><span style="color:#75715e">    arg：传给指令的参数，可选。例如 v-my-directive:foo 中，参数为 &#34;foo&#34;。
</span><span style="color:#75715e">    modifiers：一个包含修饰符的对象。例如：v-my-directive.foo.bar 中，修饰符对象为 { foo: true, bar: true }。
</span><span style="color:#75715e">vnode：Vue 编译生成的虚拟节点。
</span><span style="color:#75715e">oldVnode：上一个虚拟节点，仅在 update 和 componentUpdated 钩子中可用。
</span><span style="color:#75715e">
</span><span style="color:#75715e">这里我会在视频中结合官方样例讲解
</span><span style="color:#75715e">*/</span>
</code></pre></div><p>上面我们罗列了这么多它的特性，不过真正开发中，我们最常用的只有 bind 和 update 这两个时期
我们可以简写为</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-js" data-lang="js">    <span style="color:#a6e22e">Vue</span>.<span style="color:#a6e22e">directive</span>(<span style="color:#e6db74">&#39;color&#39;</span>, <span style="color:#66d9ef">function</span> (<span style="color:#a6e22e">el</span>, <span style="color:#a6e22e">binding</span>) {
        <span style="color:#a6e22e">el</span>.<span style="color:#a6e22e">style</span>.<span style="color:#a6e22e">backgroundColor</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">binding</span>.<span style="color:#a6e22e">value</span>
    })
</code></pre></div><p>下面我们来举个例子</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;zh-cn&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">type</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;x-template&#34;</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;shuaiQm&#34;</span>&gt;
  <span style="color:#f92672">&lt;</span><span style="color:#a6e22e">div</span><span style="color:#f92672">&gt;</span>
   
  <span style="color:#f92672">&lt;</span><span style="color:#960050;background-color:#1e0010">/div&gt;</span>
&lt;/<span style="color:#f92672">script</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
      &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">v-color</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;color&#34;</span>&gt;
          我来测试测试directive
      &lt;/<span style="color:#f92672">div</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
        <span style="color:#a6e22e">Vue</span>.<span style="color:#a6e22e">directive</span>(<span style="color:#e6db74">&#34;color&#34;</span>,<span style="color:#66d9ef">function</span>(<span style="color:#a6e22e">el</span>,<span style="color:#a6e22e">binding</span>){
            <span style="color:#a6e22e">el</span>.<span style="color:#a6e22e">style</span>.<span style="color:#a6e22e">color</span> <span style="color:#f92672">=</span> <span style="color:#a6e22e">binding</span>.<span style="color:#a6e22e">value</span>
        })
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">color</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;red&#34;</span>
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
</code></pre></div><p>好了我们可以看到加上 v-color 的这个 div 内部的文字变红了</p>
<p><strong>Vue.set</strong></p>
<p>Vue.set 官网给出的用法是 Vue.set( target, key, value ) 向响应式对象中添加一个属性，并确保这个新属性同样是响应式的，且触发视图更新。它必须用于向响应式对象上添加新属性，因为 Vue 无法探测普通的新增属性
这么听起来是有些笼统的，我给大家用代码展示一下它在我们日常开发中经常出现的场景。</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;zh-cn&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
      &lt;<span style="color:#f92672">ul</span>&gt;
        &lt;<span style="color:#f92672">li</span> <span style="color:#a6e22e">v-for</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;(item,ket) in list&#34;</span> <span style="color:#a6e22e">:key</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;key&#34;</span>&gt;{{item.hello}}&lt;/<span style="color:#f92672">li</span>&gt;
      &lt;/<span style="color:#f92672">ul</span>&gt;
      &lt;<span style="color:#f92672">button</span> <span style="color:#960050;background-color:#1e0010">@</span><span style="color:#a6e22e">click</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;addList&#34;</span>&gt;+&lt;/<span style="color:#f92672">button</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">list</span><span style="color:#f92672">:</span>[{<span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>},{<span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello two&#34;</span>}]
            },
            <span style="color:#a6e22e">methods</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">addList</span>(){
                   <span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">list</span>[<span style="color:#ae81ff">0</span>] <span style="color:#f92672">=</span> {<span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;ttt&#34;</span>}
                    <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">list</span>)
                }
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
</code></pre></div><p>在上述代码中，我们通过 this.list[0]直接修改了数组中的第 0 项目对象，那么视图是没有更新的，但是数据确实变更了，这是为什么呢？因为 Vue 是通过 Object.defineProperty()来进行数据的监听，它的机制导致了它无法直接检测出数组中这种情况的变化。这时候我们就需要使用 Vue.set 了</p>
<div class="highlight"><pre style="color:#f8f8f2;background-color:#272822;-moz-tab-size:4;-o-tab-size:4;tab-size:4"><code class="language-html" data-lang="html"><span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;zh-cn&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
      &lt;<span style="color:#f92672">ul</span>&gt;
        &lt;<span style="color:#f92672">li</span> <span style="color:#a6e22e">v-for</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;(item,ket) in list&#34;</span> <span style="color:#a6e22e">:key</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;key&#34;</span>&gt;{{item.hello}}&lt;/<span style="color:#f92672">li</span>&gt;
      &lt;/<span style="color:#f92672">ul</span>&gt;
      &lt;<span style="color:#f92672">button</span> <span style="color:#960050;background-color:#1e0010">@</span><span style="color:#a6e22e">click</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;addList&#34;</span>&gt;+&lt;/<span style="color:#f92672">button</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">list</span><span style="color:#f92672">:</span>[{<span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>},{<span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello two&#34;</span>}]
            },
            <span style="color:#a6e22e">methods</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">addList</span>(){
                   <span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">list</span>[<span style="color:#ae81ff">0</span>] <span style="color:#f92672">=</span> {<span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;ttt&#34;</span>}
                    <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">list</span>)
                }
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
<span style="color:#75715e">&lt;!DOCTYPE html&gt;</span>
&lt;<span style="color:#f92672">html</span> <span style="color:#a6e22e">lang</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;zh-cn&#34;</span>&gt;
&lt;<span style="color:#f92672">head</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">charset</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;UTF-8&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">name</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;viewport&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;width=device-width, initial-scale=1.0&#34;</span>&gt;
    &lt;<span style="color:#f92672">meta</span> <span style="color:#a6e22e">http-equiv</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;X-UA-Compatible&#34;</span> <span style="color:#a6e22e">content</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;ie=edge&#34;</span>&gt;
    &lt;<span style="color:#f92672">title</span>&gt;Document&lt;/<span style="color:#f92672">title</span>&gt;
&lt;/<span style="color:#f92672">head</span>&gt;
 
&lt;<span style="color:#f92672">body</span>&gt;
    &lt;<span style="color:#f92672">div</span> <span style="color:#a6e22e">id</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;app&#34;</span>&gt;
      &lt;<span style="color:#f92672">ul</span>&gt;
        &lt;<span style="color:#f92672">li</span> <span style="color:#a6e22e">v-for</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;(item,ket) in list&#34;</span> <span style="color:#a6e22e">:key</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;key&#34;</span>&gt;{{item.hello}}&lt;/<span style="color:#f92672">li</span>&gt;
      &lt;/<span style="color:#f92672">ul</span>&gt;
      &lt;<span style="color:#f92672">button</span> <span style="color:#960050;background-color:#1e0010">@</span><span style="color:#a6e22e">click</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;addList&#34;</span>&gt;+&lt;/<span style="color:#f92672">button</span>&gt;
    &lt;/<span style="color:#f92672">div</span>&gt;
 
    &lt;<span style="color:#f92672">script</span> <span style="color:#a6e22e">src</span><span style="color:#f92672">=</span><span style="color:#e6db74">&#34;https://cdn.jsdelivr.net/npm/vue/dist/vue.js&#34;</span>&gt;&lt;/<span style="color:#f92672">script</span>&gt;
    &lt;<span style="color:#f92672">script</span>&gt;
 
        <span style="color:#66d9ef">var</span> <span style="color:#a6e22e">app</span> <span style="color:#f92672">=</span> <span style="color:#66d9ef">new</span> <span style="color:#a6e22e">Vue</span>({
            <span style="color:#a6e22e">el</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;#app&#34;</span>,
            <span style="color:#a6e22e">data</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">list</span><span style="color:#f92672">:</span>[{<span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello world&#34;</span>},{<span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;hello two&#34;</span>}]
            },
            <span style="color:#a6e22e">methods</span><span style="color:#f92672">:</span>{
                <span style="color:#a6e22e">addList</span>(){
                <span style="color:#75715e">//    this.list[0] = {hello:&#34;ttt&#34;}
</span><span style="color:#75715e"></span>                    <span style="color:#a6e22e">Vue</span>.<span style="color:#a6e22e">set</span>(<span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">list</span>,<span style="color:#ae81ff">0</span>, {<span style="color:#a6e22e">hello</span><span style="color:#f92672">:</span><span style="color:#e6db74">&#34;我强制改变了！&#34;</span>})
                    <span style="color:#75715e">// this.$set(this.list,0,{hello:&#34;我强制改变了！&#34;})  在methods 中可以写成 this.$set 
</span><span style="color:#75715e"></span>                    <span style="color:#a6e22e">console</span>.<span style="color:#a6e22e">log</span>(<span style="color:#66d9ef">this</span>.<span style="color:#a6e22e">list</span>)
                }
            }
        })
    &lt;/<span style="color:#f92672">script</span>&gt;
&lt;/<span style="color:#f92672">body</span>&gt;
&lt;/<span style="color:#f92672">html</span>&gt;
 
</code></pre></div><p>看 是不是强制将它改变了呢？ 有了 Vue.set 数据就都不再得瑟了</p>

        </div>

        
<div class="post-archive">
    <ul class="post-copyright">
        <li><strong>原文作者：</strong><a rel="author" href="https://luckly.work/">luckly</a></li>
        <li style="word-break:break-all"><strong>原文链接：</strong><a href="https://luckly.work/post/vue/Vue%E7%BB%84%E4%BB%B6%E5%BC%80%E5%8F%91%E4%BB%A5%E5%8F%8A%E5%B8%B8%E7%94%A8%E5%85%A8%E5%B1%80api/">https://luckly.work/post/vue/Vue%E7%BB%84%E4%BB%B6%E5%BC%80%E5%8F%91%E4%BB%A5%E5%8F%8A%E5%B8%B8%E7%94%A8%E5%85%A8%E5%B1%80api/</a></li>
        <li><strong>版权声明：</strong>本作品采用<a rel="license" href="https://creativecommons.org/licenses/by-nc-nd/4.0/">知识共享署名-非商业性使用-禁止演绎 4.0 国际许可协议</a>进行许可，非商业转载请注明出处（作者，原文链接），商业转载请联系作者获得授权。</li>
    </ul>
</div>
<br/>



        

<div class="post-archive">
    <h2>See Also</h2>
    <ul class="listing">
        
        <li><a href="/post/vue/Vue.js%E7%9A%84%E8%B5%B7%E6%AD%A5/">Vue.js 起步</a></li>
        
        <li><a href="/post/vue/Vue.js%E7%9A%84%E7%9B%AE%E5%BD%95%E7%BB%93%E6%9E%84/">Vue.js 目录结构</a></li>
        
        <li><a href="/post/vue/Vue.js%E7%9A%84%E5%AE%89%E8%A3%85/">Vue.js 安装</a></li>
        
        <li><a href="/post/python_basic/python3%E6%A0%87%E5%87%86%E5%BA%93%E8%A7%84%E8%8C%83/">Python3标准库规范</a></li>
        
        <li><a href="/post/python_basic/python3%E5%91%BD%E5%90%8D%E7%A9%BA%E9%97%B4%E4%BD%9C%E7%94%A8%E5%9F%9F/">Python3命名空间作用域</a></li>
        
    </ul>
</div>


        <div class="post-meta meta-tags">
            
            <ul class="clearfix">
                
                <li><a href='/tags/Vue'>Vue</a></li>
                
            </ul>
            
        </div>
    </article>
    
    

    
    
    <div class="post bg-white">
      <script src="https://utteranc.es/client.js"
            repo= "https://github.com/ITmxs/repo"
            issue-term="pathname"
            theme="github-light"
            crossorigin="anonymous"
            async>
      </script>
    </div>
    
</div>

                    <footer id="footer">
    <div>
        &copy; 2021 <a href="https://luckly.work/">早起的年轻人 By luckly</a>
        
        | <a rel="nofollow" target="_blank" href="http://beian.miit.gov.cn/">粤ICP备2021号-1</a>
        
    </div>
    <br />
    <div>
        <div class="github-badge">
            <a href="https://juejin.cn/user/3843548384077192" target="_black" rel="nofollow"><span class="badge-subject">Powered by</span><span class="badge-value bg-blue">掘金</span></a>
        </div>
        <div class="github-badge">
            <a href="https://space.bilibili.com/480883651" target="_black"><span class="badge-subject">Design by</span><span class="badge-value bg-brightgreen">早起的年轻人</span></a>
        </div>
        <div class="github-badge">
            <a href="https://cloud.tencent.com/developer/user/6702670" target="_black"><span class="badge-subject">Theme</span><span class="badge-value bg-yellowgreen">云社区</span></a>
        </div>
    </div>
</footer>


    
    <script type="text/javascript">
        window.MathJax = {
            tex2jax: {
                inlineMath: [['$', '$']],
                processEscapes: true
                }
            };
    </script>
    <script src='https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML' async></script><script src="https://cdn.bootcdn.net/ajax/libs/fancybox/3.5.7/jquery.fancybox.min.js"></script>

<a id="rocket" href="#top"></a>
<script type="text/javascript" src='/js/totop.js?v=0.0.0' async=""></script>



    <script type="text/javascript" src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" async></script>




    <script src='/js/douban.js'></script>
    <script src="/js/copy-to-clipboard.js"></script>

                </div>

                <div id="secondary">
    <section class="widget">
        <form id="search" action='https://luckly.work/search/' method="get" accept-charset="utf-8" target="_blank" _lpchecked="1">
      
      <input type="text" name="q" maxlength="20" placeholder="Search">
      <input type="hidden" name="sitesearch" value="https://luckly.work/">
      <button type="submit" class="submit icon-search"></button>
</form>
    </section>
    
    <section class="widget">
        <h3 class="widget-title">最近文章</h3>
<ul class="widget-list">
    
    <li>
        <a href="https://luckly.work/post/nginx/nginx%E6%96%87%E4%BB%B6%E5%86%85%E5%AE%B9/" title="Nginx文件内容">Nginx文件内容</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/nginx/nginx%E6%9E%81%E7%AE%80%E6%95%99%E7%A8%8B/" title="Nginx极简教程">Nginx极简教程</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/nginx/%E5%8D%81%E5%88%86%E9%92%9F%E5%85%A5%E9%97%A8nginx/" title="十分钟入门Nginx">十分钟入门Nginx</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/go/Goland%E8%BF%9C%E7%A8%8B%E5%BC%80%E5%8F%91%E9%85%8D%E7%BD%AE/" title="Goland远程开发配置">Goland远程开发配置</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/%E8%AF%BB%E4%B9%A6/%E5%9F%9F%E5%90%8D%E8%A7%A3%E6%9E%90/" title="域名解析">域名解析</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/git/%E6%8F%90%E4%BA%A4%E8%BF%87%E7%A8%8B%E7%9C%81%E7%95%A5%E6%9F%90%E4%BA%9B%E6%96%87%E4%BB%B6/" title="提交过程省略某些文件">提交过程省略某些文件</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/flutter_tips/Flutter_DropdownButton%E7%A4%BA%E4%BE%8B/" title="Flutter_DropdownButton示例">Flutter_DropdownButton示例</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/flutter_tips/Flutter_ExpansionPanelList%E5%92%8CExpansionPanelList.radio%E7%A4%BA%E4%BE%8B/" title="Flutter_ExpansionPanelList和ExpansionPanelList">Flutter_ExpansionPanelList和ExpansionPanelList</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/flutter_tips/Flutter%E5%BE%AE%E4%BF%A1%E5%88%86%E4%BA%AB%E9%93%BE%E6%8E%A5%E8%B7%B3%E5%9B%9EApp%E6%8C%87%E5%AE%9A%E9%A1%B5%E9%9D%A2/" title="Flutter微信分享链接跳回App指定页面">Flutter微信分享链接跳回App指定页面</a>
    </li>
    
    <li>
        <a href="https://luckly.work/post/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F/%E5%A4%96%E5%8C%85%E5%8F%AF%E8%83%BD%E7%9A%84%E9%97%AE%E9%A2%98/" title="外包可能的问题">外包可能的问题</a>
    </li>
    
</ul>
    </section>

    

    <section class="widget">
        <h3 class="widget-title"><a href='/categories/'>分类</a></h3>
<ul class="widget-list">
    
    <li><a href="https://luckly.work/categories/Flutter/">Flutter (326)</a></li>
    
    <li><a href="https://luckly.work/categories/IT/">IT (2)</a></li>
    
    <li><a href="https://luckly.work/categories/Kotlin/">Kotlin (2)</a></li>
    
    <li><a href="https://luckly.work/categories/Mysql/">Mysql (1)</a></li>
    
    <li><a href="https://luckly.work/categories/nginx/">nginx (1)</a></li>
    
    <li><a href="https://luckly.work/categories/Vue/">Vue (6)</a></li>
    
    <li><a href="https://luckly.work/categories/YouTube%E8%A7%86%E9%A2%91%E4%B8%8B%E8%BD%BD/">YouTube视频下载 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/android/">android (6)</a></li>
    
    <li><a href="https://luckly.work/categories/dart/">dart (96)</a></li>
    
    <li><a href="https://luckly.work/categories/Flutter/">Flutter (28)</a></li>
    
    <li><a href="https://luckly.work/categories/gin/">gin (25)</a></li>
    
    <li><a href="https://luckly.work/categories/git/">git (4)</a></li>
    
    <li><a href="https://luckly.work/categories/Go/">Go (102)</a></li>
    
    <li><a href="https://luckly.work/categories/gorm/">gorm (4)</a></li>
    
    <li><a href="https://luckly.work/categories/grpc/">grpc (1)</a></li>
    
    <li><a href="https://luckly.work/categories/html/">html (3)</a></li>
    
    <li><a href="https://luckly.work/categories/ios/">ios (1)</a></li>
    
    <li><a href="https://luckly.work/categories/linux/">linux (1)</a></li>
    
    <li><a href="https://luckly.work/categories/nginx/">nginx (6)</a></li>
    
    <li><a href="https://luckly.work/categories/python/">python (35)</a></li>
    
    <li><a href="https://luckly.work/categories/read/">读书笔记 (6)</a></li>
    
    <li><a href="https://luckly.work/categories/redis/">redis (2)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%B8%AA%E4%BA%BA%E8%B5%84%E6%96%99/">个人资料 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%B9%A6%E5%8D%95/">书单 (8)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%B9%A6%E8%AF%84/">书评 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E5%B8%88/">信息系统管理师 (19)</a></li>
    
    <li><a href="https://luckly.work/categories/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E5%B8%88/">信息系统项目管理师 (25)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%8E%9F%E5%88%99/">原则 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%8E%9F%E7%94%9F%E9%80%9A%E8%AE%AF/">原生通讯 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%9F%BA%E7%A1%80/">基础 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%A4%8D%E5%88%A9%E6%95%88%E5%BA%94/">复利效应 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">安装教程 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%B0%91%E6%9C%89%E4%BA%BA%E8%B5%B0%E7%9A%84%E8%B7%AF/">少有人走的路 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E5%BF%83%E8%AF%AD/">心语 (3)</a></li>
    
    <li><a href="https://luckly.work/categories/%E6%8F%92%E4%BB%B6/">插件 (2)</a></li>
    
    <li><a href="https://luckly.work/categories/%E6%95%99%E5%AD%A6/">教学 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%8E%8B%E9%98%B3%E6%98%8E/">王阳明 (3)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%94%B5%E5%AD%90%E4%B9%A6/">电子书 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%99%BB%E9%99%86%E8%A1%A8%E5%8D%95/">登陆表单 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%A8%BB%E7%9B%9B%E5%92%8C%E5%A4%AB/">稻盛和夫 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%A9%B7%E7%88%B8%E7%88%B8%E5%AF%8C%E7%88%B8%E7%88%B8/">穷爸爸富爸爸 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%B2%BE%E8%BF%9B/">精进 (3)</a></li>
    
    <li><a href="https://luckly.work/categories/%E7%BC%96%E7%A8%8B/">编程 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%99%9A%E5%B9%BB/">虚幻 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%B4%A2%E5%8A%A1%E8%87%AA%E7%94%B1%E4%B9%8B%E8%B7%AF/">财务自由之路 (2)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%B7%91%E6%AD%A5/">跑步 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%B7%AF%E7%94%B1%E4%BC%A0%E5%8F%82/">路由传参 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%B7%AF%E7%BA%BF/">路线 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E8%BD%AF%E4%BB%B6%E5%AE%9E%E6%96%BD/">软件实施 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E9%98%B3%E6%98%8E%E5%BF%83%E5%AD%A6/">阳明心学 (3)</a></li>
    
    <li><a href="https://luckly.work/categories/%E9%A1%B9%E7%9B%AE/">项目 (1)</a></li>
    
    <li><a href="https://luckly.work/categories/%E9%AD%85%E5%8A%9B/">魅力 (1)</a></li>
    
</ul>
    </section>

    <section class="widget">
        <h3 class="widget-title"><a href='/tags/'>标签</a></h3>
<div class="tagcloud">
    
    <a href="https://luckly.work/tags/flutter/">flutter</a>
    
    <a href="https://luckly.work/tags/IT/">IT</a>
    
    <a href="https://luckly.work/tags/Kotlin/">Kotlin</a>
    
    <a href="https://luckly.work/tags/Mysql/">Mysql</a>
    
    <a href="https://luckly.work/tags/nginx/">nginx</a>
    
    <a href="https://luckly.work/tags/Vue/">Vue</a>
    
    <a href="https://luckly.work/tags/YouTube%E8%A7%86%E9%A2%91%E4%B8%8B%E8%BD%BD/">YouTube视频下载</a>
    
    <a href="https://luckly.work/tags/android/">android</a>
    
    <a href="https://luckly.work/tags/dart/">dart</a>
    
    <a href="https://luckly.work/tags/flutter/">flutter</a>
    
    <a href="https://luckly.work/tags/gin/">gin</a>
    
    <a href="https://luckly.work/tags/git/">git</a>
    
    <a href="https://luckly.work/tags/go/">go</a>
    
    <a href="https://luckly.work/tags/gorm/">gorm</a>
    
    <a href="https://luckly.work/tags/grpc/">grpc</a>
    
    <a href="https://luckly.work/tags/html/">html</a>
    
    <a href="https://luckly.work/tags/ios/">ios</a>
    
    <a href="https://luckly.work/tags/linux/">linux</a>
    
    <a href="https://luckly.work/tags/nginx/">nginx</a>
    
    <a href="https://luckly.work/tags/python/">python</a>
    
    <a href="https://luckly.work/tags/redis/">redis</a>
    
    <a href="https://luckly.work/tags/%E4%B8%AA%E4%BA%BA%E8%B5%84%E6%96%99/">个人资料</a>
    
    <a href="https://luckly.work/tags/%E4%B9%A6%E5%8D%95/">书单</a>
    
    <a href="https://luckly.work/tags/%E4%B9%A6%E8%AF%84/">书评</a>
    
    <a href="https://luckly.work/tags/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F%E7%AE%A1%E7%90%86%E5%B8%88/">信息系统管理师</a>
    
    <a href="https://luckly.work/tags/%E4%BF%A1%E6%81%AF%E7%B3%BB%E7%BB%9F%E9%A1%B9%E7%9B%AE%E7%AE%A1%E7%90%86%E5%B8%88/">信息系统项目管理师</a>
    
    <a href="https://luckly.work/tags/%E5%85%A5%E9%97%A8/">入门</a>
    
    <a href="https://luckly.work/tags/%E5%8E%9F%E5%88%99/">原则</a>
    
    <a href="https://luckly.work/tags/%E5%8E%9F%E7%94%9F%E9%80%9A%E8%AE%AF/">原生通讯</a>
    
    <a href="https://luckly.work/tags/%E5%9F%BA%E7%A1%80/">基础</a>
    
    <a href="https://luckly.work/tags/%E5%A4%8D%E5%88%A9%E6%95%88%E5%BA%94/">复利效应</a>
    
    <a href="https://luckly.work/tags/%E5%AE%89%E8%A3%85%E6%95%99%E7%A8%8B/">安装教程</a>
    
    <a href="https://luckly.work/tags/%E5%B0%91%E6%9C%89%E4%BA%BA%E8%B5%B0%E7%9A%84%E8%B7%AF/">少有人走的路</a>
    
    <a href="https://luckly.work/tags/%E5%BF%83%E8%AF%AD/">心语</a>
    
    <a href="https://luckly.work/tags/%E6%8F%92%E4%BB%B6/">插件</a>
    
    <a href="https://luckly.work/tags/%E6%95%99%E5%AD%A6/">教学</a>
    
    <a href="https://luckly.work/tags/%E7%8E%8B%E9%98%B3%E6%98%8E/">王阳明</a>
    
    <a href="https://luckly.work/tags/%E7%94%B5%E5%AD%90%E4%B9%A6/">电子书</a>
    
    <a href="https://luckly.work/tags/%E7%99%BB%E9%99%86%E8%A1%A8%E5%8D%95/">登陆表单</a>
    
    <a href="https://luckly.work/tags/%E7%A8%BB%E7%9B%9B%E5%92%8C%E5%A4%AB/">稻盛和夫</a>
    
    <a href="https://luckly.work/tags/%E7%A9%B7%E7%88%B8%E7%88%B8%E5%AF%8C%E7%88%B8%E7%88%B8/">穷爸爸富爸爸</a>
    
    <a href="https://luckly.work/tags/%E7%B2%BE%E8%BF%9B/">精进</a>
    
    <a href="https://luckly.work/tags/%E7%BC%96%E7%A8%8B/">编程</a>
    
    <a href="https://luckly.work/tags/%E8%99%9A%E5%B9%BB/">虚幻</a>
    
    <a href="https://luckly.work/tags/%E8%AF%97/">诗</a>
    
    <a href="https://luckly.work/tags/%E8%AF%BB%E4%B9%A6%E7%AC%94%E8%AE%B0/">读书笔记</a>
    
    <a href="https://luckly.work/tags/%E8%B4%A2%E5%8A%A1%E8%87%AA%E7%94%B1%E4%B9%8B%E8%B7%AF/">财务自由之路</a>
    
    <a href="https://luckly.work/tags/%E8%B7%91%E6%AD%A5/">跑步</a>
    
    <a href="https://luckly.work/tags/%E8%B7%AF%E7%94%B1%E4%BC%A0%E5%8F%82/">路由传参</a>
    
    <a href="https://luckly.work/tags/%E8%B7%AF%E7%BA%BF/">路线</a>
    
    <a href="https://luckly.work/tags/%E8%BD%AF%E4%BB%B6%E5%AE%9E%E6%96%BD/">软件实施</a>
    
    <a href="https://luckly.work/tags/%E9%80%9A%E8%AE%AF%E5%BD%95/">通讯录</a>
    
    <a href="https://luckly.work/tags/%E9%98%B3%E6%98%8E%E5%BF%83%E5%AD%A6/">阳明心学</a>
    
    <a href="https://luckly.work/tags/%E9%A1%B9%E7%9B%AE/">项目</a>
    
    <a href="https://luckly.work/tags/%E9%AD%85%E5%8A%9B/">魅力</a>
    
</div>
    </section>

    
<section class="widget">
    <h3 class="widget-title">友情链接</h3>
    <ul class="widget-list">
        
        <li>
            <a target="_blank" href="http://www.topgoer.com/" title="枯藤">枯藤</a>
        </li>
        
        <li>
            <a target="_blank" href="https://gorm.cn/zh_CN/docs/index.html" title="gorm">gorm</a>
        </li>
        
        <li>
            <a target="_blank" href="https://docs.python.org/zh-cn/3/tutorial/index.html" title="python">python</a>
        </li>
        
        <li>
            <a target="_blank" href="https://www.liwenzhou.com/" title="李文周">李文周的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="http://www.xbzweb.com/" title="小包子的博客">小包子的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="https://www.flysnow.org/" title="飞雪无情的博客">飞雪无情的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="https://sliverhorn.com/" title="sliverhorn的博客">sliverhorn的博客</a>
        </li>
        
        <li>
            <a target="_blank" href="http://yuedu.baidu.com/ebook/14a722970740be1e640e9a3e" title="Android Gradle权威指南">Android Gradle权威指南</a>
        </li>
        
        <li>
            <a target="_blank" href="https://gesdh.cn/" title="小格子">格子导航</a>
        </li>
        
        <li>
            <a target="_blank" href="https://itachi.xyz/" title="阿林">itachi&#39;s Blog</a>
        </li>
        
        <li>
            <a target="_blank" href="https://darjun.github.io/" title="大俊">大俊Blog</a>
        </li>
        
        <li>
            <a target="_blank" href="https://geektutu.com/post/quick-golang.html" title="极客兔兔">极客兔兔Blog</a>
        </li>
        
        <li>
            <a target="_blank" href="http://zxfcumtcs.github.io/" title="赵雪峰">雪峰Blog</a>
        </li>
        
    </ul>
</section>


    <section class="widget">
        <h3 class="widget-title">其它</h3>
        <ul class="widget-list">
            <li><a href="https://luckly.work/index.xml">文章 RSS</a></li>
        </ul>
    </section>
</div>
            </div>
        </div>
    </div>
</body>

</html>